package com.example.iterator.Impi;

import com.example.iterator.Iterator;

public class IteratorImpi implements Iterator {
    private Object[] elements;
    private int index;

    public IteratorImpi(Object[] elements) {
        this.elements = elements;
        this.index = 0;
    }

    @Override
    public boolean hasNext() {
        return index < elements.length;
    }

    @Override
    public Object next() {
        if (hasNext()) {
            return elements[index++];
        }

        return null;
    }
}
